home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2579 < prev    next >
Encoding:
Text File  |  1996-08-06  |  3.3 KB  |  116 lines

  1. Path: vax.sbu.ac.uk!tonyh
  2. From: tonyh@vax.sbu.ac.uk
  3. Newsgroups: comp.lang.c++
  4. Subject: Problem calling LIB$FIND_FILE on VAX
  5. Date: 18 Jan 96 13:57:59 GMT
  6. Organization: South Bank University
  7. Message-ID: <1996Jan18.135759.1@vax.sbu.ac.uk>
  8. NNTP-Posting-Host: big.sbu.ac.uk
  9.  
  10. Hi everyone,
  11.  
  12. I'm having difficulty trying to call the lib$find_file(,,,,,,) VAX
  13. Run-Time-Library (RTL) command from within a C program. I think my
  14. problem is not with the parameters of the actual lib$ call itself,
  15. but with the "$descriptor" part that actually holds the values, I've
  16. been through the VAX manuals and the "descriptor" part is still unclear
  17. to me. Am I accessing it correctly?...
  18.  
  19. I have listed the source code below the system message, the codes purpose
  20. is to list a file in the current directory using  wildcards.  The program
  21. compiles, links but when I run it I get the following mesage:
  22.  
  23. %SYSTEM-F-ACCVIO, access violation, reason mask=01, virtual address=010E0102,
  24. PC
  25. =0003738A, PSL=03C00000
  26. %TRACE-F-TRACEBACK, symbolic stack dump follows
  27. module name     routine name                     line       rel PC    abs PC
  28.  
  29.                                                            0003738A  0003738A
  30.                                                            00033FFE  00033FFE
  31.                                                            000341EC  000341EC
  32. LCALL           main                             2979      000000C7  000004CF
  33.  
  34.  
  35. Please can you email me with some advise, suggestions, or pointers
  36. on where I am going wrong as I cannot find an explanation for the
  37. "$descriptor" procedure documented in any of the VAX manuals,
  38. thanks in advance.  
  39.             *** Tony ***
  40.  
  41.  
  42. /********************************************************************
  43.    Filename: lcall.c
  44.  
  45. ******************************************************************/
  46.  
  47. #include <stdio.h>
  48. #include <stdlib.h>
  49. #include <string.h>
  50.  
  51. #include <descrip.h>
  52. #include <ssdef.h>
  53. #include <lib$routines.h>
  54.  
  55. #include "scrn.h"
  56.  
  57. struct dsc$descriptor_s *descriptor(char *string);
  58.  
  59.  
  60. /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
  61. main()
  62. {
  63.    struct dsc$descriptor_s FileFound;
  64.  
  65.    unsigned long int ContexVar;
  66.                                      
  67.    char instr[256];
  68.    int status;
  69.  
  70.    char FName[] = "l*.*";
  71.    char ans;
  72.  
  73.    cls;
  74.    printf("\n\t*** Hello Boyz ready to start? ***\n");
  75.    ans = getchar();
  76.  
  77.    /* Here's where the fun starts */
  78.  
  79.     /* Assign values to structure variables */
  80.    FileFound.dsc$w_length  = 255;
  81.    FileFound.dsc$a_pointer = instr;
  82.    FileFound.dsc$b_class   = DSC$K_CLASS_S;    
  83.    FileFound.dsc$b_dtype   = DSC$K_DTYPE_T;    /* char string */
  84.  
  85.     /* Call library function  Lib$find_file(,,,,) */
  86.    status = lib$find_file( descriptor( FName ), FileFound,
  87.                                 ContexVar, 0, 0, 0, 1 );
  88.  
  89.    /* Check status */
  90.    if (status == SS$_NORMAL) {
  91.       FileFound.dsc$a_pointer[ FileFound.dsc$w_length ] = '\0';
  92.    }
  93.  
  94.    lib$find_file_end( ContexVar );
  95.  
  96.    /* return (0); */
  97. }
  98.  
  99. /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
  100. struct dsc$descriptor_s *descriptor(char *string)
  101. {
  102.    static struct dsc$descriptor_s desc[20];
  103.    static int count = -1;
  104.  
  105.    if (count == 20) {
  106.       count = -1;
  107.    }
  108.    count++;
  109.    desc[count].dsc$w_length = strlen(string);
  110.    desc[count].dsc$a_pointer = string;
  111.    desc[count].dsc$b_class = DSC$K_CLASS_S;
  112.    desc[count].dsc$b_dtype = DSC$K_DTYPE_T;
  113.  
  114.    return(&desc[count]);
  115. }
  116.